<%--=========================================================================== 
This is the page directive. Sets the content type and encoding.
Encoding of the response: UTF-8
Encoding of this JSP page: Cp1251 
===========================================================================--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="Cp1251"%>
<%@ taglib uri="/WEB-INF/st4" prefix="st"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<jsp:include page="/WEB-INF/includes/scripts.jsp" />
<script type="text/javascript" src="js/jQuery.js"></script>
<script type="text/javascript">

	$(document).ready(function(){
		
		getTimetable();
		
		$("#airport_selection").change(function(){
			getTimetable();
		});
	}); 
	
	function getTimetable(){
		createPopupMessage("Data is being requested");
		$("#ajax_dep_result").html('');
		var request="controller?command=ajax_online_desc&"+jQuery('#airport').serialize();
		jQuery.ajax ({
			url: request, 
			dataType : 'html',
			success: function (data, textStatus) {
				$("#ajax_dep_result").html('');
				$("#ajax_dep_result").append(data);
				closePopup(300);
			},
			error: function (msg) {
				closePopup(300); 
				createPopupMessage("Error while getting data");
			}
		});
	}
</script>
<title>Timetable</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="styles/st4.css" />
</head>
	<body>
		<table class="page">
			<%--========================================================================--%>
			<jsp:include page="/WEB-INF/includes/header.jsp" />
			<jsp:include page="/WEB-INF/includes/menu.jsp" />
			<%--========================================================================--%>
			
			<tr class="content">
				<td align="center">
					<h2><st:i18n key="pages.timetable"/></h2>
					<form id="airport">
					<table>
					<tr> 
					<td><st:i18n key="phrases.select_airport"/></td>
						<td>
							<select name="airport" id="airport_selection">
									<c:forEach var="item" items="${airportsList}">
										<c:out value="<option value=\"${item.id}\"> ${item.airportCity} ${item.airportName}" escapeXml="false">
										Nothing found
										</c:out>
									</c:forEach>
							</select>
						</td>
					</tr>
					</table>
					</form>
					
					<div style="width:80%;" id="ajax_dep_result"></div>
					
			</tr>
			<%--========================================================================--%>
			<jsp:include page="/WEB-INF/includes/footer.jsp" />
			<%--========================================================================--%>
		</table>
	</body>
</html>